/**
 * @file: vscode
 * @author: v_xieyejiang
 * @Date: 2018-12-10 11:21:55
 * @Last Modified by: v_xieyejiang
 * @Last Modified time: 2018-12-10 11:23:52
 */

import {utilsAxios} from '@/utils/';
import notice from '@/services/node/notice';

export default {
    namespaced: true,
    state: {
        notice: {}
    },
    getters: {
        notice: State => State.notice
    },
    actions: {
        async read({commit}, options) {
            const result = await notice.read(options && options.data);
            utilsAxios(options, result);
            commit('NOTICE', result.data.data || {});
        },
        async write({commit}, options) {
            const result = await notice.write(options && options.data);
            utilsAxios(options, result);
            commit('NOTICE', result.data.data || {});
        }
    },
    mutations: {
        ['NOTICE'](State, data) {
            State.notice = data;
        }
    }
};
